package practise;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 强仔
 * Date: 2021-09-22
 * Time: 21:44
 */
public class myHeap {
   public int[] elem;
   public int useSize;

    public myHeap(int[] elem) {
        this.elem = new int[10];
    }

    public void adjustDown(int[] array, int begin, int end) {
        int parent = begin;
        int child = parent * 2 + 1;
        while (child <= end) {
            if (child + 1 < array.length && array[child + 1] > array[child]) {
                child++;
            }
            if (array[parent] < array[child]) {
                int temp = array[parent];
                array[parent] = array[child];
                array[child] = temp;
                parent = child;
                child = child*2+1;
            }else{
                break;
            }
        }
    }
}
